﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using HZ.DrugTrade.BLLFactory;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.Model;
using System.Collections.Generic;
using HZ.DrugTrade.Model.Enum;

namespace HZ.DrugTrade.Web.Hospitals.Procurement
{
    public partial class CompanySelect_PS : System.Web.UI.Page
    {
        string str;
        protected void Page_Load(object sender, EventArgs e)
        {
            str = Request["type"].ToString();//要显示的企业类型 1.生产企业 2.配送企业
            if (!IsPostBack)
            {
                setBind(str);
            }
        }

        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            setBind(str);
        }

        private void setBind(string str)
        {
            IBLL_Company companyCtrl = Factory.BLL_Company();
            Model.Query.Company where = new HZ.DrugTrade.Model.Query.Company();
            where.CompanyName = txtCompanyName.Text.Trim();
            if (str.Equals("1"))
            {
                where.CompanyType = HZ.DrugTrade.Model.Enum.EnumCompanyType.生产企业;
            }
            else
            {
                where.CompanyType = HZ.DrugTrade.Model.Enum.EnumCompanyType.配送企业;
            }



            //AspNetPager1.PageSize = Constants.GRIDVIEW_PAGE_SIZE;
            int totalCount = 0;
            IList<Model.Company> companyList = companyCtrl.GetCompanyByCondition_PS(where, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount);


            //重新确定一共分多少页

            //int count = companyCtrl.GetCompanyCount("02");

            AspNetPager1.RecordCount = totalCount;
            gvwCompanyList.DataSource = companyList;
            gvwCompanyList.DataBind();
        }

        protected void btnQery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            setBind(str);
        }
    }
}
